package com.yanqu.road.server.cmd.activity.autoreward.rank;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.rank.cross.CrossUserRank;
import com.yanqu.road.logic.cross.CrossActivityRankListModel;
import com.yanqu.road.pb.activity.AutoSendRewardProto;
import com.yanqu.road.server.manager.activity.ActivityRankMgr;

import java.util.Map;

public class EveFeastActivityRank extends BaseCrossRank {

    public EveFeastActivityRank(int activityId) {
        super(activityId);
    }


    @Override
    public AutoSendRewardProto.CrossUnionRankMsg.Builder getCrossUnionRankMsg() {
        return null;
    }

    @Override
    public AutoSendRewardProto.CrossUserRankMsg.Builder getCrossUserRankMsg() {
        AutoSendRewardProto.CrossUserRankMsg.Builder msg = AutoSendRewardProto.CrossUserRankMsg.newBuilder();
        msg.setActivityId(activityId);
        Map<Integer, CrossActivityRankListModel> modelMap = ActivityRankMgr.getCrossActivityNewRankListModelMap(activityId);
        if (modelMap != null) {
            for (Map.Entry<Integer, CrossActivityRankListModel> entry : modelMap.entrySet()) {
                CrossActivityRankListModel rankListModel = entry.getValue();
                int conditionType = rankListModel.getConditionType();
                if (conditionType != eGamePlayerEventType.EveFeastUserRank.getValue()) {
                    continue;
                }
                int rank = 0;
                for (CrossUserRank rankData : rankListModel.getRankList()) {
                    long userId = rankData.getUserId();
                    rank++;
                    addUserRankData(msg, conditionType, userId, rank);
                }
            }
        }
        return msg;
    }
}
